package com.huixue.cn.ztej.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.huixue.cn.ztej.bean.LoginLogger;
import com.huixue.cn.ztej.bean.Results;
import com.huixue.cn.ztej.bean.User;
import com.huixue.cn.ztej.dao.LoginLoggerMapper;
import com.huixue.cn.ztej.utils.SystemContents.API_RETURN_STATUS;
import com.huixue.cn.ztej.utils.framwork.PageParameter;

@Service("sysLoginLoggerService")
public class SysLoginLoggerService {

	private static Logger logger = LoggerFactory.getLogger(SysConstructionTeamService.class);

	@Autowired
	private LoginLoggerMapper loginLoggerMapper;
	
	
	/**
	 * 日志列表
	 * @return
	 */
	public Results listLoggerPage(Map<String,Object> searchParams,Integer pageNumber, Integer pageSize){
		
		PageParameter page = new PageParameter();
		page.setCurrentPage(pageNumber);
		page.setPageSize(pageSize);
		searchParams.put("page", page);
		
		List<LoginLogger> list = loginLoggerMapper.listLoggerPage(searchParams);
		
		Map<String, Object> rmap = new HashMap<String, Object>();
		rmap.put("total", page.getTotalPage());
		rmap.put("page", pageNumber);						//当前页
		rmap.put("records", page.getTotalCount());			//总记录数
		rmap.put("pageSize", pageSize);						//每页个数
		
		rmap.put("rows", list);
		Results results = new Results(
				API_RETURN_STATUS.NORMAL.value(),
				API_RETURN_STATUS.NORMAL.desc(),rmap);
		return results;
		 
	}
	
	/**
	 * 添加日志
	 * @param logger
	 */
	public void addLogger(LoginLogger logger){
		 loginLoggerMapper.addLogger(logger);
	}
}
